package org.brownflat.watergate.resources.mysql;

import org.brownflat.watergate.resources.MySqlUpgrade;
import org.springframework.stereotype.Component;

/**
 * <p>&copy Rupert Jones 2011,2012</p>
 *
 * @author rup
 */
@Component
public class Upgrade0011AutoReview implements MySqlUpgrade {

    private static final int VERSION = 11;

    @Override
    public int getSequence() {
        return VERSION;
    }

    @Override
    public String getSql() {
        return "CREATE TABLE `wgate_auto_review_trigger` (\n"
                + " `id` int(11) NOT NULL AUTO_INCREMENT,\n"
                + " `branch` int(11) NOT NULL,\n"
                + " `name` varchar(255) NOT NULL,\n"
                + " `file_match` varchar(255),\n"
                + " `user_match` int(11),\n"
                + " `all_commits` int(11) NOT NULL DEFAULT '0',\n"
                + " `enabled` int(11) NOT NULL DEFAULT '1',\n"
                + " `file_count_match` int(11) NOT NULL DEFAULT '0',\n"
                + "  `created_at` timestamp NOT NULL,\n"
                + "  `updated_at` timestamp NOT NULL,\n"
                + "  UNIQUE KEY `name_brch_UNIQUE` (`name`, `branch`),\n"
                + "  PRIMARY KEY (`id`)\n"
                + ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;";
    }

    @Override
    public String getName() {
        return "Create auto review trigger";
    }
}
